import 'dart:math';

import 'package:get/get.dart';

import '../../../../model/build_info.dart';
import '../../../../model/lift_info.dart';
import '../../../../utils/eventbus.dart';
import '../../../../utils/utils_logger.dart';

class GroupAllLogic extends GetxController {


  var buildInfo = BuildInfo().obs;

  var liftList = <LiftInfo>[].obs;

  @override
  void onReady() {
    super.onReady();
    bus.on(bus.buildInfoKey, (arg) {
      buildInfo.value = arg;
      for (var lift in arg.liftInfoStateMaps.values) {
        var having = false;
        for (var i = 0; i < liftList.length; i++) {
          if (liftList[i].order == lift.order) {
            having = true;
            liftList[i] = lift;
            break;
          }
        }
        if (!having) {
          liftList.add(lift);
        }
      }
      logd('buildInfo -------------------------->----- ${liftList.length}');
    });
  }

  @override
  void onClose() {
    // TODO: implement onClose
    super.onClose();
  }
}
